package com.spc.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.spc.entity.PageResult;
import com.spc.entity.QueryPageBean;
import com.spc.service.HealthInterventionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;



/*
健康干预相关类
* */
//用RestController,表示在controller的基础上增减responsebody,不跳转到到视图
@RestController
@RequestMapping("/healthIntervention")
public class HealthInterventionController {

    // 需要用@Referencr注解,找到对应的服务
    @Reference
    private HealthInterventionService healthInterventionService;



    /*
    分页展示人群分类表
    需要将表单提交的数据通过Requestbody,将json数据封存到queryPageBean对象中
    * */
    @RequestMapping("/querypage")
    // 给查询会员设置权限控制注解(通过数据库中权限唯一表示符remark表示)
    @PreAuthorize("hasAuthority('USER_QUERY')")
    public PageResult queryPage(@RequestBody QueryPageBean queryPageBean)  {
        // 1.调用healthInterventionService中的queryPage方法,将queryPageBean传递过去,返回pageResult对象
        PageResult pageResult = healthInterventionService.queryPage(queryPageBean);
        // 2.返回pageResult,并会自动将其转换为json字符串
        return pageResult;
    }


}
